home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
opbonus.arc
/
ALARM.ARC
/
ALARMI.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-03-20
|
4KB
|
134 lines
;ALARMI.ASM - Int 1Ch handler and supporting routines for ALARM.PAS
;by TurboPower Software
CODE SEGMENT BYTE PUBLIC
ASSUME CS:CODE,DS:NOTHING
PUBLIC EnableTasks,DisableTasks,Int1CHandler,AlarmCSData
EXTRN SetPopTicker:Far
;Structure of a pointer
Pointer STRUC
Ofst DW 0
Segm DW 0
Pointer ENDS
;the following label is used by the pascal code to locate the CS
;relative data
AlarmCSData:
TickCountToPop dd 0 ;the tick count to popup on
TickDataPtr Pointer <> ;pointer to userdata of IFCRecord
TasksEnabled db 0 ;enabled flag
Save1C Pointer <> ;save original int 1Ch vector
InInt1C db 0
SaveAllRegs MACRO
PUSH BP
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH ES
PUSH SI
PUSH DI
ENDM
RestoreAllRegs MACRO
POP DI
POP SI
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
POP BP
ENDM
Int1CHandler PROC FAR
;first, emulate int 1C to call original vector
PUSHF
CALL DWORD PTR Save1C
STI ; enable interrupts
;save regs we will use (whether alarm time or not)
PUSH DS
PUSH BX
PUSH AX
MOV BX,40h
MOV DS,BX
MOV BX,6Ch ;make DS:BX point to BIOS tick count
MOV AX,word ptr CS:TickCountToPop
;compare low words of current tick count to alarm tick count
CMP AX,[BX]
JNE Int1CExit ;if not equal, then exit
INC BX
INC BX
MOV AX,word ptr CS:TickCountToPop+2
;compare high words
CMP AX,[BX]
JNE Int1CExit ;if not equal, then exit
;if we make it here then it is time to popup alarm
SaveAllRegs
XOR AX,AX
LES DI, TickDataPtr ; point to ThisIFC.UserData
CLD ; clear direction flag
STOSW ; put a zero longint in it
STOSW
MOV AX, 07FFFh
PUSH AX ; push the ticker count
CALL SetPopTicker ;equivelent to SetPopTicker($7FFF);
RestoreAllRegs
Int1CExit:
;restore the regs that are always used
POP AX
POP BX
POP DS
IRET
Int1CHandler ENDP
;save original int 1Ch vector and install new one
EnableTasks PROC FAR
TEST CS:TasksEnabled,1 ;check enabled flag
JNZ ET_Exit ;if already enabled, then exit
PUSH DS ;save DS
MOV AX,CS ;make DS = CS
MOV DS,AX
MOV AX,351Ch
INT 21h ;get current int 1Ch
MOV Save1C.Ofst,BX ;save for later
MOV BX,ES
MOV Save1C.Segm,BX
MOV DX,OFFSET Int1CHandler
MOV AX,251Ch
INT 21h ;set up our int 1Ch handler
MOV CS:TasksEnabled,1 ;set enabled flag
POP DS ;restore DS
ET_Exit:
RET
EnableTasks ENDP
;restore original int 1Ch handler
DisableTasks PROC FAR
TEST CS:TasksEnabled,1 ;see if tasks are enabled
JZ DT_Exit ;if not then exit
PUSH DS
MOV AX,CS:Save1C.Segm
MOV DX,CS:Save1C.Ofst
MOV DS,AX
MOV AX,251Ch ;put back original int 1Ch handler
INT 21h
MOV CS:TasksEnabled,0 ;clear enabled flag
POP DS
DT_Exit:
RET
DisableTasks ENDP
CODE ENDS
END